<template>
<!-- 订单详情页 -->
  <div class="order-set">
    <div class="order-detail container" v-loading="loading">
      <div class="top flex-space-bet">
        <div class="left">
          <div class="img">
            <span class="iconfont">&#xe617;</span>
          </div>
          <div class="detail">
            <h3 class="title">订单提交成功！去付款咯～</h3>
            <p>请在<span class='red'>0小时30分</span>内完成支付, 超时后将取消订单</p>
            <p>收货信息：{{addrDetail.receiverName}} {{addrDetail.receiverMobile}} {{addrDetail.receiverProvince}} {{addrDetail.receiverCity}} {{addrDetail.receiverDistrict}} {{addrDetail.receiverAddress}}</p>
          </div>
        </div>
        <div class="right">
          <div class="price">应付总额：<span class='red'>{{totalPrice}}</span>元</div>
          <div class="order-detail-btn" @click='showDetail'>
            订单详情<span class="iconfont">&#xe615;</span>
          </div>
        </div>
      </div>
      <!-- 订单详情信息 -->
      <div class="products-order-detail" v-show='detailShow'>
        <div class="detail">
          <div class="item">
            <div class="name">订单号：</div>
            <div class="desc red">{{payInfo.orderNo}}</div>
          </div>
          <div class="item">
            <div class="name">收货信息：</div>
            <div class="desc">{{addrDetail.receiverName}} {{addrDetail.receiverMobile}} {{addrDetail.receiverProvince}} {{addrDetail.receiverCity}} {{addrDetail.receiverDistrict}} {{addrDetail.receiverAddress}}</div>
          </div>
          <div class="item">
            <div class="name">商品名称：</div>
            <div class="desc">
              <p v-for="item of productList" :key="item.productId">
                <img :src="item.productImage"><span>{{item.productName}}</span>
              </p>
            </div>
          </div>
          <div class="item">
            <div class="name">发票信息：</div>
            <div class="desc">电子发票 个人</div>
          </div>
        </div>
      </div>
    </div>
    <!-- 支付方式 -->
    <div class="payment-method container">
      <h3 class="title">选择以下支付方式付款</h3>
      <p>支付平台</p>
      <img src="/imgs/pay/icon-ali.png" />
      <img src="/imgs/pay/icon-wechat.png" @click="showWx" />
    </div>
    <wx-container v-show='wxShow' @changeWx='changeWx'></wx-container>
  </div>
</template>

<script>
import WxContainer from "./Wx"
export default {
  name: "OrderSet",
  data(){
    return{
      loading: true,
      detailShow: false,
      wxShow: false,
      addrDetail: {},
      productList: {},
      totalPrice: '',
      payInfo: {},
    }
  },
  mounted(){
    this.getPayInfo()
    // console.log(this.$route.params.id)
  },
  methods: {
    showDetail(){
      this.detailShow = !this.detailShow;
    },
    showWx(){
      this.wxShow = true;
    },
    changeWx(){
      this.wxShow = false;
    },
    getPayInfo(){
      var d = this.$route.params.id;
      // console.log(d);
      this.axios.get(`/orders/${d}`).then(res => {
        this.addrDetail = res.shippingVo;
        this.totalPrice = res.payment;
        this.payInfo = res;
        this.productList = res.orderItemVoList
        this.loading = false
        // console.log(res.orderItemVoList)
      },() => {
        this.loading = false;
      })
    }
  },
  components: {
    WxContainer
  }
};
</script>

<style lang="scss">
.order-set {
  background: #eee;
  padding: 20px 0;
  min-height: 500px;
  // 订单
  .order-detail {
    padding: 40px 20px;
    background: #fff;
    align-items: center;
    .left {
      display: flex;
      .iconfont {
        font-size: 80px;
        line-height: 100px;
        margin-left: 30px;
        color: rgba(0, 128, 0, 0.603);
      }
      .detail {
        margin: 0 30px;
      }
      .title {
        font-size: 24px;
        line-height: 60px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #333333;
        text-align: left;
        letter-spacing: 2px;
      }
      p {
        font-size: 14px;
        line-height: 20px;
        letter-spacing: 1px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #666666;
        text-align: left;
      }
    }
    .right {
      .price {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #666666;
        text-align: right;
        line-height: 60px;
        .red {
          font-size: 28px;
        }
      }
      .order-detail-btn {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #666666;
        text-align: right;
        cursor: pointer;
      }
    }
    // 订单详情信息
    .products-order-detail{
      border-top: 1px solid #eee;
      margin-top: 40px;
      padding: 40px 130px;
      line-height: 34px;
      transition: all 1s;
      .item{
        display: flex;
        .name{
          width: 100px;
        }
        .desc,p,.name{
          text-align: left;
        }
        img{
          width: 20px;
          vertical-align: middle;
          margin-right: 10px;
        }
      }
    }
  }
  // 支付方式
  .payment-method {
    padding: 0 40px 40px;
    background: #fff;
    align-items: center;
    margin-top: 20px;
    text-align: left;
    p,
    h3 {
      text-align: left;
      font-family: PingFang SC;
      font-weight: bold;
      color: #333333;
      line-height: 60px;
    }
    h3 {
      font-size: 20px;
      border-bottom: 1px solid #eee;
    }
    p {
      font-size: 18px;
    }
    img {
      border: 1px solid #eee;
      width: 188px;
      height: 64px;
      margin-right: 20px;
      cursor: pointer;
    }
  }
}
</style>